home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / PHPUnit / TestFailure.php < prev    next >
PHP Script  |  2004-10-01  |  3KB  |  89 lines

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: PHPUnit                                                        |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2003 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
  7. // +------------------------------------------------------------------------+
  8. // | This source file is subject to version 3.00 of the PHP License,        |
  9. // | that is available at http://www.php.net/license/3_0.txt.               |
  10. // | If you did not receive a copy of the PHP license and are unable to     |
  11. // | obtain it through the world-wide-web, please send a note to            |
  12. // | license@php.net so we can mail you a copy immediately.                 |
  13. // +------------------------------------------------------------------------+
  14. //
  15. // $Id: TestFailure.php,v 1.7 2004/04/17 08:12:06 sebastian Exp $
  16. //
  17.  
  18. /**
  19.  * A TestFailure collects a failed test together with the caught exception.
  20.  *
  21.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  22.  * @copyright   Copyright © 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
  23.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  24.  * @category    PHP
  25.  * @package     PHPUnit
  26.  */
  27. class PHPUnit_TestFailure {
  28.     /**
  29.     * @var    object
  30.     * @access private
  31.     */
  32.     var $_failedTest;
  33.  
  34.     /**
  35.     * @var    string
  36.     * @access private
  37.     */
  38.     var $_thrownException;
  39.  
  40.     /**
  41.     * Constructs a TestFailure with the given test and exception.
  42.     *
  43.     * @param  object
  44.     * @param  string
  45.     * @access public
  46.     */
  47.     function PHPUnit_TestFailure(&$failedTest, &$thrownException) {
  48.         $this->_failedTest      = $failedTest;
  49.         $this->_thrownException = $thrownException;
  50.     }
  51.  
  52.     /**
  53.     * Gets the failed test.
  54.     *
  55.     * @return object
  56.     * @access public
  57.     */
  58.     function &failedTest() {
  59.         return $this->_failedTest;
  60.     }
  61.  
  62.     /**
  63.     * Gets the thrown exception.
  64.     *
  65.     * @return object
  66.     * @access public
  67.     */
  68.     function &thrownException() {
  69.         return $this->_thrownException;
  70.     }
  71.  
  72.     /**
  73.     * Returns a short description of the failure.
  74.     *
  75.     * @return string
  76.     * @access public
  77.     */
  78.     function toString() {
  79.         return sprintf(
  80.           "TestCase %s->%s() failed: %s\n",
  81.  
  82.           get_class($this->_failedTest),
  83.           $this->_failedTest->getName(),
  84.           $this->_thrownException
  85.         );
  86.     }
  87. }
  88. ?>
  89.